#include <iostream>

class calculation  //抽象类:具有纯虚函数的类
// 抽象类不能实例化
{
public:
    virtual int calculate(int a,int b) = 0;  //纯虚函数
};

//继承自抽象类的类仍然是抽象类，只有重写了纯虚数才可以实例化
class Add:public calculation
{
public:
    virtual int calculate(int a, int b)
    {
        return a + b;
    }

};

class Minus:public calculation
{
public:
    virtual int calculate(int a, int b)
    {
        return a - b;
    }

};

class Multiply:public calculation
{
public:
    virtual int calculate(int a, int b)
    {
        return a * b;
    }

};

class devide:public calculation
{
public:
    virtual int calculate(int a, int b)
    {
        return a / b;
    }

};

void calculate(calculation *c,int a,int b)
{
    std::cout<<c->calculate(a,b)<<std::endl;
}

int main()
{
    calculate(new Multiply,1,2);
    return 0;
}